package com.itheima.reggie.common;

import java.util.Arrays;

public class Demo {
    public static void main(String[] args) {
        int[] arr = new int[]{1, 6, 8, 9, 2, 3, 5, 4, 7};
        for (int i = 0; i < arr.length - 1; i++) {
            int minIndex = i;
            int minNum = arr[i];
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[j] < minNum) {
                    minNum = arr[j];
                    minIndex = j;
                }
            }
            arr[minIndex] = arr[i];
            arr[i] = minNum;
            System.out.println(i + "---===---   :" );
            System.out.println(Arrays.toString(arr));
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
        }
    }
}
